package com.freely.util;

import java.util.Base64;

public class Base64Util {
	public static String encode(byte[] data) {
		if(data == null || data.length == 0) {
			throw new IllegalArgumentException();
		}
		String result = Base64.getEncoder().encodeToString(data);
		return result;
	}
	
	public static byte[] decode(String data) {
		if(data == null || data.trim().length() == 0) {
			throw new IllegalArgumentException();
		}
		byte[] result = Base64.getDecoder().decode(data);
		return result;
	}
}
